package game;

import java.awt.Graphics2D;
import java.awt.Point;
import java.awt.geom.Point2D;

public class HUD 
{
	private Point size;
	private GameObject go1, go2;
	private int Proporcao;
	private int wDelay;
	public boolean FINISHEDTIME;
	public Point initialPosition;
	public int IDtrabalhador;
	
	public HUD(int go1Image, int go2Image, Point position, Point size) 
	{
		this.initialPosition = position;
		this.size = size;
		this.go1 = new GameObject(position, size);
		this.go2 = new GameObject(position, new Point(0, size.y));
		this.go1.setImage(go1Image);
		this.go2.setImage(go2Image);
		this.FINISHEDTIME = false;
	}
	
	public void RestoreHUD()
	{
		go2 = new GameObject(initialPosition, new Point(0, size.y));
	}
	public void SetIDIcone(int IDIcone)
	{
	}
	
	public void SetIDTrabalhador(int IDTrabalhador)
	{
	}
	
	public void SetDelay(int WrongDelay, int idtrabalhador)
	{
		this.wDelay = WrongDelay;
		this.IDtrabalhador = idtrabalhador;
	}
	
	public void Update()
	{
		if (!FINISHEDTIME)
		{
			this.Proporcao = this.size.x / this.wDelay;
			
			this.go2.dimension = new Point2D.Double(go2.dimension.getX() + this.Proporcao * Time.getInstance().loopTime, go2.dimension.getY());
			
			if(this.go2.dimension.getX() >= this.size.x)
			{
				go2.dimension = new Point2D.Double(size.x, go2.dimension.getY());
				this.FINISHEDTIME = true;
				
				switch(IDtrabalhador)
				{
				case 1:
					Personagem.Tecnicos++;
					break;
				case 2:Personagem.ConsertaPoste++;
					break;
				case 3:Personagem.ConsertaAntena++;
					break;
				}			
			}
		}
	}
	public void Draw(Graphics2D g2d, Camera camera)
	{
		go1.draw(g2d, camera);
		go2.draw(g2d, camera);
	}
}
